/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package event;

import file.PrintFile;
import file.PrintToPrinter;
import java.awt.BorderLayout;
import java.io.IOException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import model.Protocol;

/**
 *
 * @author joao
 */
public class GetEvent {
    
    private String str;

    public static class autor {

    }

    public GetEvent() {
    }

    public void configurationEvent() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public void imprimirEvent(String ano, String quantidade, 
            String valorInicial, String controle ) throws IOException {
        Vector<String> v = new Protocol(quantidade, valorInicial, ano, controle ).getProtocols();
        str = new PrintFile(v).getWriter();
        PrintToPrinter a = new PrintToPrinter(str);
        visualizarEvent();
        if ( JOptionPane.showConfirmDialog(null, "Deseja imprimir o arquivo?", "Confirmar", JOptionPane.YES_NO_OPTION) == 0) {
            a.printFile();
        } else
            JOptionPane.showMessageDialog(null, "Impressao cancelada");
        
        
    //  Runtime.getRuntime().exec("evince /home/joao/PDF/_Java_Printing.pdf");
    }

    public void visualizarEvent() {
        try {
            Runtime.getRuntime().exec("evince //tmp/file.000");
        } catch (IOException ex) {
            Logger.getLogger(GetEvent.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    

    public void autor() {
        JFrame f = new JFrame( "Autor");
        JTextArea a = new JTextArea("Cefet CE UnED Maracanau" +
                "\nGerenciador de Protocolos versao 0.6b " +
                "\n" +
                "\n" +
                "\n" +
                "Joao Neto - 2008");
        a.setEditable(false);
        f.setLayout(new BorderLayout());
        
        f.add (a);
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.setSize(300,200);
        f.setLocation(400, 300);
        f.setVisible(true);

    }    

}
